package com.ruoyi.custom.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.custom.domain.PotentialClients;
import com.ruoyi.custom.service.IPotentialClientsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 潜在客户Controller
 * 
 * @author ruoyi
 * @date 2024-03-25
 */
@RestController
@RequestMapping("/clients")
public class PotentialClientsController extends BaseController
{
    @Autowired
    private IPotentialClientsService potentialClientsService;




    // regular 学员转正
    @PostMapping("/regular/{ids}")
    public void regular(@PathVariable Long[] ids)
    {
        potentialClientsService.regular(ids);
    }


    /**
     * 分配咨询
     */

    @PostMapping("/addTeacherClients/{ids}")
    public void addTeacherClients(@PathVariable  Long[] ids)
    {
        potentialClientsService.addTeacherClients(ids);
    }

    /**
     * 查询潜在客户列表
     */
    @RequiresPermissions("custom:clients:list")
    @GetMapping("/list")
    public TableDataInfo list(PotentialClients potentialClients)
    {
        startPage();
        List<PotentialClients> list = potentialClientsService.selectPotentialClientsList(potentialClients);
        return getDataTable(list);
    }

    /**
     * 导出潜在客户列表
     */
    @RequiresPermissions("custom:clients:export")
    @Log(title = "潜在客户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PotentialClients potentialClients)
    {
        List<PotentialClients> list = potentialClientsService.selectPotentialClientsList(potentialClients);
        ExcelUtil<PotentialClients> util = new ExcelUtil<PotentialClients>(PotentialClients.class);
        util.exportExcel(response, list, "潜在客户数据");
    }

    /**
     * 获取潜在客户详细信息
     */
    @RequiresPermissions("custom:clients:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(potentialClientsService.selectPotentialClientsById(id));
    }

    /**
     * 新增潜在客户
     */
    @RequiresPermissions("custom:clients:add")
    @Log(title = "潜在客户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PotentialClients potentialClients)
    {
        return toAjax(potentialClientsService.insertPotentialClients(potentialClients));
    }

    /**
     * 修改潜在客户
     */
    @RequiresPermissions("custom:clients:edit")
    @Log(title = "潜在客户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PotentialClients potentialClients)
    {
        return toAjax(potentialClientsService.updatePotentialClients(potentialClients));
    }

    /**
     * 删除潜在客户
     */
    @RequiresPermissions("custom:clients:remove")
    @Log(title = "潜在客户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(potentialClientsService.deletePotentialClientsByIds(ids));
    }
}
